home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-31 | 1.5 KB | 70 lines | [TEXT/PJMM] |
- unit MyDesktopDB;
-
- interface
-
- function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
- { You can safely ignore the error and use the returned rn in calls to Get/Set, they will just bounce }
- procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: str255);
- procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: str255);
-
- implementation
-
- const
- bad_rn = -1;
-
- function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
- var
- pb: DTPBRec;
- oe: OSErr;
- v: longInt;
- begin
- rn := bad_rn;
- oe := Gestalt(gestaltDBAccessMgrAttr, v);
- if (oe = noErr) & not BTST(v, gestaltDBAccessMgrPresent) then
- oe := -1;
- if oe = noErr then begin
- pb.ioNamePtr := nil;
- pb.ioVRefNum := vrn;
- oe := PBDTGetPath(@pb);
- if oe = noErr then
- rn := pb.ioDTRefNum;
- end;
- GetDesktopDB := oe;
- end;
-
- procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: str255);
- var
- pb: DTPBRec;
- oe: OSErr;
- begin
- s := '';
- if rn <> bad_rn then begin
- pb.ioNamePtr := @fs.name;
- pb.ioDTRefNum := rn;
- pb.ioDTBuffer := @s[1];
- pb.ioDirID := fs.parID;
- oe := PBDTGetComment(@pb, false);
- if oe = noErr then begin
- s[0] := chr(pb.ioDTActCount);
- end
- else
- s := '';
- end;
- end;
-
- procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: str255);
- var
- pb: DTPBRec;
- oe: OSErr;
- begin
- if rn <> bad_rn then begin
- pb.ioNamePtr := @fs.name;
- pb.ioDTRefNum := rn;
- pb.ioDTBuffer := @s[1];
- pb.ioDTReqCount := length(s);
- pb.ioDirID := fs.parID;
- oe := PBDTSetComment(@pb, false);
- end;
- end;
-
- end.